package com.gengzp.rpc.core.impl;

import com.gengzp.rpc.constants.RpcCommonConstants;
import com.gengzp.rpc.core.EnvironmentReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @ClassName EnvironmentReaderImpl
 * @Description 环境变量读取器实现类
 * @Author gengzp
 * @Date 2025/6/1 0:22
 */
@Component
public class EnvironmentReaderImpl implements EnvironmentReader {

    @Autowired
    private Environment environment;

    @Override
    public String getCurrentNacosAddress() {
        return environment.getProperty(RpcCommonConstants.NACOS_ADDRESS);
    }

    @Override
    public String getCurrentNacosGroup() {
        return environment.getProperty(RpcCommonConstants.NACOS_GROUP);
    }

    @Override
    public String getCurrentNacosNamespace() {
        return environment.getProperty(RpcCommonConstants.NACOS_NAMESPACE);
    }

    @Override
    public String getCurrentServiceName() {
        return environment.getProperty(RpcCommonConstants.CURRENT_SERVICE_NAME);
    }

}
